package com.ruyidd.threads;

import com.ruyidd.consts.BartenderConsts;
import com.ruyidd.entity.BartenderParams;
import com.ruyidd.utils.BartenderUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: tianxc
 * @Date: 2024年06月28 20时14分08秒
 * @Description: TODO
 */
public class BartenderPrintThread extends Thread {

    Logger log = LoggerFactory.getLogger(BartenderPrintThread.class);
    private BartenderParams bartenderParams;

    public BartenderPrintThread(BartenderParams bartenderParams) {
        this.bartenderParams = bartenderParams;
    }

    @Override
    public void run() {
        try {
            if (BartenderConsts.DATA_TYPE_EMBEDED.equals(bartenderParams.getDataType())) {
                BartenderUtils.embeddedDataPrint(bartenderParams);
            } else {
                BartenderUtils.txtDataPrint(bartenderParams);
            }
        } catch (Exception e) {
            log.info("嵌入式数据源异步打印异常:" + e.getMessage());
            throw new RuntimeException(e);
        }
    }
}
